package com.example.jixeishi1.controller;


import com.example.jixeishi1.entity.ProductEntity;
import com.example.jixeishi1.service.ProductService;
import com.example.jixeishi1.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;


@Controller
public class ProductController {
    @Autowired
    private ProductService productService;

    /**
     * 列表
     */
    @RequestMapping("commod/listcommod")
    public R list(){
        List<ProductEntity> productEntityList = new ArrayList<>();
        productEntityList = productService.getCommodityEntity();
        ModelMap map = new ModelMap();
        map.put("page", productEntityList);
        return R.ok().put("commod", productEntityList);
    }



    /**
     * 保存
     */
    @RequestMapping("/commodity/save")
    public R save(@RequestBody ProductEntity commodity){

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/commodity/update")
    public R update(@RequestBody ProductEntity commodity){

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/commodity/delete")
    public R delete(@RequestBody Integer[] ids){

        return R.ok();
    }

}
